import 'package:appflutterhomeschool/ui/widgets/bottom_navigation_bar_widget.dart';
import 'package:flutter/material.dart';

import 'academic_sentiment/academic_sentiment_page.dart';
import 'letter/letter_page.dart';
import 'notice/notice_page.dart';
import 'user/my_page.dart';

///用户：Nine Tailed Fox
///时间：2020/6/8
///邮箱：1037438704@qq.com
///功能：主页面

class MainTabPage extends StatefulWidget {
  @override
  _MainTabPageState createState() => _MainTabPageState();
}

class _MainTabPageState extends State<MainTabPage> {
  int _currentIndex = 0;

  PageController _pageController;
  bool flag = true;

  @override
  void initState() {
    super.initState();
    this._pageController = PageController(initialPage: this._currentIndex);
  }

  void _onTapHandler(index) {
    setState(() {
      this._currentIndex = index;
      this._pageController.jumpToPage(this._currentIndex);
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: PageView(
        physics: NeverScrollableScrollPhysics(),
        controller: this._pageController,
        children: [
          NoticePage(),
          LetterPage(),
          AcademicSentimetPage(),
          MyPage(),
        ],
      ),
      bottomNavigationBar: BottomNavigationBarWidget(
        currentIndex: _currentIndex,
        changedOnTap: _onTapHandler,
      ),
    );
  }
}
